<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('brokerages', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->default(0)->index();
            $table->unsignedBigInteger('order_id')->default(0)->index();
            $table->unsignedBigInteger('product_id')->default(0)->index();
            $table->unsignedBigInteger('product_sku_id')->default(0)->index();
            $table->unsignedBigInteger('seckill_product_id')->default(0);
            $table->dateTime('settled_at')->nullable();
            $table->dateTime('disabled_at')->nullable()->comment('order cancelled or refunded');
            $table->string('remark')->nullable()->index();
            $table->string('reason')->nullable();
            $table->string('type')->nullable();
            $table->decimal('money', 10, 2)->default(0);
            $table->decimal('pay_money', 10, 2)->default(0);
            $table->boolean('is_taken')->default(false)->comment('是否领取');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('brokerages');
    }
};
